package com.vg.chat;

import com.SlideMenu.chatlove.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class SampleFragment extends Fragment {
	private DiscussArrayAdapter adapter;
	private ListView lv;
	private EditText editText1;

	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.chat, null);
	}

	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		adapter = new DiscussArrayAdapter(getActivity(),
				R.layout.chat_listitem_chat);
		lv = (ListView) getView().findViewById(R.id.listView1);
		lv.setAdapter(adapter);

		editText1 = (EditText) getView().findViewById(R.id.editText1);
		Button btn1 = (Button) getView().findViewById(R.id.btn1);
		Button btn2 = (Button) getView().findViewById(R.id.btn2);
		btn1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (!editText1.getText().toString().equals("")) {
					adapter.add(new OneComment(true, editText1.getText()
							.toString()));
					editText1.setText("");
				}
			}
		});
		btn2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (!editText1.getText().toString().equals("")) {
					adapter.add(new OneComment(false, editText1.getText()
							.toString()));
					editText1.setText("");
				}
			}
		});

	}
}
